package com.util;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

/**
 * 
* @ClassName: GetConfig
* @Description: 获取配置文件参数
*
 */
public class GetConfig {
    
    private static boolean notLoad = true;
    
    private static Map<String,String> map=new HashMap<String,String>(); 
    
	static{
        init();
    }

    private static void init() {
        try{
        	String configName = "config.system_config";
        	ResourceBundle p = ResourceBundle.getBundle(configName);
            Enumeration<String> keys = p.getKeys();
            while(keys.hasMoreElements()){
            	String key=keys.nextElement();
            	map.put(key, p.getString(key));
            }
            notLoad=false;
        }catch(Exception e){
        	e.printStackTrace();
        }
    }
    
    public static String getString(String key){
    	if (notLoad) {
    		init();
    	}
    	return map.get(key);
    }
    
    public static String getFileoutputpath(){
    	if (notLoad) {
    		init();
    	}
    	return map.get("fileoutputPath");
    }
    
    public static String getLocalFilePath(){
    	if (notLoad) {
    		init();
    	}
    	return map.get("localFilePath");
    }
    public static int getCachePeriod(){
    	if (notLoad) {
    		init();
    	}
    	return Integer.parseInt(map.get("CachePeriod"));
    }
    public static String getLogLevel(){
    	if (notLoad) {
    		init();
    	}
    	return map.get("LogLevel");
    }
    public static String getLogEnabled(){
    	if (notLoad) {
    		init();
    	}
    	return map.get("LogEnabled");
    }
    
}
